package com.xtpt.disaster.utils;

import com.xtpt.disaster.bean.JobDetail;
import com.xtpt.disaster.bean.TaskInfo;

import java.util.Date;

/**
 * @author jack_xin
 * @ClassName JobDetailAutowired
 * @Desc 接收定时调度传来的taskinfo自动注入到jobdetail中
 * @date 2021年12月01日 11:03
 * @Version v1.0
 */
public class ClassInjected {
    public static JobDetail injectJobDetail(TaskInfo taskInfo, String serverPath) {

        JobDetail jobDetail = new JobDetail();
        Long jobId = IDGenerator.longid();
        Long taskId = taskInfo.getTaskId();
        String jobName = taskInfo.getTaskName();
        Integer jobType = taskInfo.getTaskType();
        Long nodeId = taskInfo.getNodeId();
        Integer jobBackupType = taskInfo.getTaskBackupType();
        Integer scheduleType = taskInfo.getTaskExectype();
        String clientPath = taskInfo.getTaskClientPath();
        Integer dataType = taskInfo.getTaskFileType();
        Integer fileType = taskInfo.getTaskFileType();
        String jobDesc = taskInfo.getTaskDesc();
        Date jobStratTime = new Date();

        jobDetail.setJobId(jobId);
        jobDetail.setJobName(jobName);
        jobDetail.setJobType(jobType);
        jobDetail.setNodeId(nodeId);
        jobDetail.setScheduleType(scheduleType);
        jobDetail.setServerPath(serverPath);
        jobDetail.setJobBackupType(jobBackupType);
        jobDetail.setClientPath(clientPath);
        jobDetail.setDataType(dataType);
        jobDetail.setFileType(fileType);
        jobDetail.setTaskId(taskId);
        jobDetail.setJobDesc(jobDesc);
        jobDetail.setJobStartTime(jobStratTime);

        return jobDetail;
    }
}
